
"""
Germany
Source: http://en.wikipedia.org/wiki/Public_holidays_in_Germany

Except for the national holiday (German Unity Day), public holidays in Germany (gesetzliche Feiertage) are determined by the federal states.

"""

import sys
sys.path.append("/home/thomas/SpyderProjects/")
sys.path.append("/home/thomas/SpyderProjects/pycalendar/")

from datetime import date, datetime
from pycalendar.holidayprofiles import HolidayProfile
from pycalendar.holidayprofiles.holidayprofile import *

class BW(HolidayProfile):

    """ Holiday profile for Germany/Baden Wuerttemberg.
        Source: http://en.wikipedia.org/wiki/Public_holidays_in_Germany
        
        >>> German_Unity = datetime(2010, 10, 03) #Sunday
        >>> BW.holiday(German_Unity)
        'German Unity Day'
        
        >>> BW.isHoliday(German_Unity)
        True

        >>> BW.isBusinessDay(German_Unity)
        False
        
        >>> BW.isWeekend(German_Unity)
        True
    """

    weekend = [Saturday, Sunday]
        
    holidaydict = {
    "New Year's Day"    : '(d == 1 and m == January)',
    "Epiphany"          : '(d == 6 and m == January)',    
    "Good Friday"       : '(date== gf)',
    "Easter Monday"     : '(date == em)',
    "Labour Day"        : '(d == 1 and m == May)',
    "Ascension Day"     : '(date == es + 39 * dayoffset)',
    "Whit Monday"       : '(date == es + 50 * dayoffset)',
    "Corpus Christi"    : '(date == es + 60 * dayoffset)',
    "Day of German Unity": '(d == 17 and m == June and (y < 1990 and y > 1953))',
    "German Unity Day"  : '(d == 3 and m == October and y >= 1990)',
    "All Saints"        : '(d == 1 and m == November)',
    "Day of Repentance and Prayer"  : '((d < 23 and d > 16) and w == Wednesday and m == November and y < 1995)',
    "Christmas"         : '(d == 25 and m == December)',
    "Christmas Day"     : '(d == 26 and m == December)'
    }

class BY(HolidayProfile):

    """ Holiday profile for Germany/Bayern.
        Source: http://en.wikipedia.org/wiki/Public_holidays_in_Germany
        
        >>> German_Unity = datetime(2010, 10, 03) #Sunday
        >>> BY.holiday(German_Unity)
        'German Unity Day'
        
        >>> BY.isHoliday(German_Unity)
        True

        >>> BY.isBusinessDay(German_Unity)
        False
        
        >>> BY.isWeekend(German_Unity)
        True
    """

    weekend = [Saturday, Sunday]
        
    holidaydict = {
    "New Year's Day"    : '(d == 1 and m == January)',
    "Epiphany"          : '(d == 6 and m == January)', 
    "Good Friday"       : '(date== gf)',
    "Easter Monday"     : '(date == em)',
    "Labour Day"        : '(d == 1 and m == May)',
    "Ascension Day"     : '(date == es + 39 * dayoffset)',
    "Whit Monday"       : '(date == es + 50 * dayoffset)',
    "Corpus Christi"    : '(date == es + 60 * dayoffset)',
    "Day of German Unity": '(d == 17 and m == June and (y < 1990 and y > 1953))',
    "Assumption Day"    : '(d == 15 and m == August) #Only in the approx. 1700 communities with mostly Catholic inhabitants and in the cities of Augsburg and Munich',
    "German Unity Day"  : '(d == 3 and m == October and y >= 1990)',
    "All Saints"        : '(d == 1 and m == November)',
    "Day of Repentance and Prayer"  : '((d < 23 and d > 16) and w == Wednesday and m == November and y < 1995)',
    "Christmas"         : '(d == 25 and m == December)',
    "Christmas Day"     : '(d == 26 and m == December)'
    }

class BE(HolidayProfile):

    """ Holiday profile for Germany/Berlin.
        Source: http://en.wikipedia.org/wiki/Public_holidays_in_Germany
        
        >>> German_Unity = datetime(2010, 10, 03) #Sunday
        >>> BE.holiday(German_Unity)
        'German Unity Day'
        
        >>> BE.isHoliday(German_Unity)
        True

        >>> BE.isBusinessDay(German_Unity)
        False
        
        >>> BE.isWeekend(German_Unity)
        True
    """

    weekend = [Saturday, Sunday]
        
    holidaydict = {
    "New Year's Day"    : '(d == 1 and m == January)',
    "Good Friday"       : '(date== gf)',
    "Easter Monday"     : '(date == em)',
    "Labour Day"        : '(d == 1 and m == May)',
    "Ascension Day"     : '(date == es + 39 * dayoffset)',
    "Whit Monday"       : '(date == es + 50 * dayoffset)',
    "Day of German Unity": '(d == 17 and m == June and (y < 1990 and y > 1953))',
    "German Unity Day"  : '(d == 3 and m == October and y >= 1990)',
    "Day of Repentance and Prayer"  : '((d < 23 and d > 16) and w == Wednesday and m == November and y < 1995)',
    "Christmas"         : '(d == 25 and m == December)',
    "Christmas Day"     : '(d == 26 and m == December)'
    }

class BB(HolidayProfile):

    """ Holiday profile for Germany/Brandenburg
        Source: http://en.wikipedia.org/wiki/Public_holidays_in_Germany
        
        >>> German_Unity = datetime(2010, 10, 03) #Sunday
        >>> BB.holiday(German_Unity)
        'German Unity Day'
        
        >>> BB.isHoliday(German_Unity)
        True

        >>> BB.isBusinessDay(German_Unity)
        False
        
        >>> BB.isWeekend(German_Unity)
        True
    """

    weekend = [Saturday, Sunday]
        
    holidaydict = {
    "New Year's Day"    : '(d == 1 and m == January)',
    "Good Friday"       : '(date== gf)',
    "Easter Monday"     : '(date == em)',
    "Labour Day"        : '(d == 1 and m == May)',
    "Ascension Day"     : '(date == es + 39 * dayoffset)',
    "Whit Monday"       : '(date == es + 50 * dayoffset)',
    "Day of German Unity": '(d == 17 and m == June and (y < 1990 and y > 1953))',
    "German Unity Day"  : '(d == 3 and m == October and y >= 1990)',
    "Reformation Day"   : '(d == 31 and m == October)',
    "Day of Repentance and Prayer"  : '((d < 23 and d > 16) and w == Wednesday and m == November and y < 1995)',
    "Christmas"         : '(d == 25 and m == December)',
    "Christmas Day"     : '(d == 26 and m == December)'
    }

class HB(HolidayProfile):

    """ Holiday Profile for Germany/Hansestadt Bremen.
        Source: http://en.wikipedia.org/wiki/Public_holidays_in_Germany
        
        >>> German_Unity = datetime(2010, 10, 03) #Sunday
        >>> HB.holiday(German_Unity)
        'German Unity Day'
        
        >>> HB.isHoliday(German_Unity)
        True

        >>> HB.isBusinessDay(German_Unity)
        False
        
        >>> HB.isWeekend(German_Unity)
        True
    """

    weekend = [Saturday, Sunday]
        
    holidaydict = {
    "New Year's Day"    : '(d == 1 and m == January)',
    "Good Friday"       : '(date== gf)',
    "Easter Monday"     : '(date == em)',
    "Labour Day"        : '(d == 1 and m == May)',
    "Ascension Day"     : '(date == es + 39 * dayoffset)',
    "Whit Monday"       : '(date == es + 50 * dayoffset)',
    "Day of German Unity": '(d == 17 and m == June and (y < 1990 and y > 1953))',
    "German Unity Day"  : '(d == 3 and m == October and y >= 1990)',
    "Day of Repentance and Prayer"  : '((d < 23 and d > 16) and w == Wednesday and m == November and y < 1995)',
    "Christmas"         : '(d == 25 and m == December)',
    "Christmas Day"     : '(d == 26 and m == December)'
    }

class HH(HolidayProfile):

    """ Holiday Profile for Germany/Hansestadt Hamburg.
        Source: http://en.wikipedia.org/wiki/Public_holidays_in_Germany
        
        >>> German_Unity = datetime(2010, 10, 03) #Sunday
        >>> HH.holiday(German_Unity)
        'German Unity Day'
        
        >>> HH.isHoliday(German_Unity)
        True

        >>> HH.isBusinessDay(German_Unity)
        False
        
        >>> HH.isWeekend(German_Unity)
        True
    """

    weekend = [Saturday, Sunday]
        
    holidaydict = {
    "New Year's Day"    : '(d == 1 and m == January)',
    "Good Friday"       : '(date== gf)',
    "Easter Monday"     : '(date == em)',
    "Labour Day"        : '(d == 1 and m == May)',
    "Ascension Day"     : '(date == es + 39 * dayoffset)',
    "Whit Monday"       : '(date == es + 50 * dayoffset)',
    "Day of German Unity": '(d == 17 and m == June and (y < 1990 and y > 1953))',
    "German Unity Day"  : '(d == 3 and m == October and y >= 1990)',
    "Day of Repentance and Prayer"  : '((d < 23 and d > 16) and w == Wednesday and m == November and y < 1995)',
    "Christmas"         : '(d == 25 and m == December)',
    "Christmas Day"     : '(d == 26 and m == December)'
    }

class HE(HolidayProfile):

    """ Holiday Profile for Germany/Hessen.
        Source: http://en.wikipedia.org/wiki/Public_holidays_in_Germany
        
        >>> German_Unity = datetime(2010, 10, 03) #Sunday
        >>> HE.holiday(German_Unity)
        'German Unity Day'
        
        >>> HE.isHoliday(German_Unity)
        True

        >>> HE.isBusinessDay(German_Unity)
        False
        
        >>> HE.isWeekend(German_Unity)
        True
    """

    weekend = [Saturday, Sunday]
        
    holidaydict = {
    "New Year's Day"    : '(d == 1 and m == January)',
    "Good Friday"       : '(date== gf)',
    "Easter Monday"     : '(date == em)',
    "Labour Day"        : '(d == 1 and m == May)',
    "Ascension Day"     : '(date == es + 39 * dayoffset)',
    "Whit Monday"       : '(date == es + 50 * dayoffset)',
    "Corpus Christi"    : '(date == es + 60 * dayoffset)',
    "Day of German Unity": '(d == 17 and m == June and (y < 1990 and y > 1953))',
    "German Unity Day"  : '(d == 3 and m == October and y >= 1990)',
    "Day of Repentance and Prayer"  : '((d < 23 and d > 16) and w == Wednesday and m == November and y < 1995)',
    "Christmas"         : '(d == 25 and m == December)',
    "Christmas Day"     : '(d == 26 and m == December)'
    }

class MV(HolidayProfile):

    """ Holiday Profile for Germany/Mecklenburg-Vorpommern.
        Source: http://en.wikipedia.org/wiki/Public_holidays_in_Germany
        
        >>> German_Unity = datetime(2010, 10, 03) #Sunday
        >>> MV.holiday(German_Unity)
        'German Unity Day'
        
        >>> MV.isHoliday(German_Unity)
        True

        >>> MV.isBusinessDay(German_Unity)
        False
        
        >>> MV.isWeekend(German_Unity)
        True
    """

    weekend = [Saturday, Sunday]
        
    holidaydict = {
    "New Year's Day"    : '(d == 1 and m == January)',
    "Good Friday"       : '(date== gf)',
    "Easter Monday"     : '(date == em)',
    "Labour Day"        : '(d == 1 and m == May)',
    "Ascension Day"     : '(date == es + 39 * dayoffset)',
    "Whit Monday"       : '(date == es + 50 * dayoffset)',
    "Day of German Unity": '(d == 17 and m == June and (y < 1990 and y > 1953))',
    "German Unity Day"  : '(d == 3 and m == October and y >= 1990)',
    "Reformation Day"   : '(d == 31 and m == October)',
    "Day of Repentance and Prayer"  : '((d < 23 and d > 16) and w == Wednesday and m == November and y < 1995)',
    "Christmas"         : '(d == 25 and m == December)',
    "Christmas Day"     : '(d == 26 and m == December)'
    }


class NI(HolidayProfile):

    """ Holiday Profile for Germany/Niedersachsen.
        Source: http://en.wikipedia.org/wiki/Public_holidays_in_Germany
        
        >>> German_Unity = datetime(2010, 10, 03) #Sunday
        >>> NI.holiday(German_Unity)
        'German Unity Day'
        
        >>> NI.isHoliday(German_Unity)
        True

        >>> NI.isBusinessDay(German_Unity)
        False
        
        >>> NI.isWeekend(German_Unity)
        True
    """

    weekend = [Saturday, Sunday]
        
    holidaydict = {
    "New Year's Day"    : '(d == 1 and m == January)',
    "Good Friday"       : '(date== gf)',
    "Easter Monday"     : '(date == em)',
    "Labour Day"        : '(d == 1 and m == May)',
    "Ascension Day"     : '(date == es + 39 * dayoffset)',
    "Whit Monday"       : '(date == es + 50 * dayoffset)',
    "Day of German Unity": '(d == 17 and m == June and (y < 1990 and y > 1953))',
    "German Unity Day"  : '(d == 3 and m == October and y >= 1990)',
    "Day of Repentance and Prayer"  : '((d < 23 and d > 16) and w == Wednesday and m == November and y < 1995)',
    "Christmas"         : '(d == 25 and m == December)',
    "Christmas Day"     : '(d == 26 and m == December)'
    }

class NW(HolidayProfile):

    """ Holiday Profile for Germany/Nordrhein-Westphalen.
        Source: http://en.wikipedia.org/wiki/Public_holidays_in_Germany
        
        >>> German_Unity = datetime(2010, 10, 03) #Sunday
        >>> NW.holiday(German_Unity)
        'German Unity Day'
        
        >>> NW.isHoliday(German_Unity)
        True

        >>> NW.isBusinessDay(German_Unity)
        False
        
        >>> NW.isWeekend(German_Unity)
        True
    """

    weekend = [Saturday, Sunday]
        
    holidaydict = {
    "New Year's Day"    : '(d == 1 and m == January)',
    "Good Friday"       : '(date== gf)',
    "Easter Monday"     : '(date == em)',
    "Labour Day"        : '(d == 1 and m == May)',
    "Ascension Day"     : '(date == es + 39 * dayoffset)',
    "Whit Monday"       : '(date == es + 50 * dayoffset)',
    "Corpus Christi"    : '(date == es + 60 * dayoffset)',
    "Day of German Unity": '(d == 17 and m == June and (y < 1990 and y > 1953))',
    "German Unity Day"  : '(d == 3 and m == October and y >= 1990)',
    "All Saints"        : '(d == 1 and m == November)',
    "Day of Repentance and Prayer"  : '((d < 23 and d > 16) and w == Wednesday and m == November and y < 1995)',
    "Christmas"         : '(d == 25 and m == December)',
    "Christmas Day"     : '(d == 26 and m == December)'
    }

class RP(HolidayProfile):

    """ Holiday Profile for Germany/Rheinland-Pfalz.
        Source: http://en.wikipedia.org/wiki/Public_holidays_in_Germany
        
        >>> German_Unity = datetime(2010, 10, 03) #Sunday
        >>> RP.holiday(German_Unity)
        'German Unity Day'
        
        >>> RP.isHoliday(German_Unity)
        True

        >>> RP.isBusinessDay(German_Unity)
        False
        
        >>> RP.isWeekend(German_Unity)
        True
    """

    weekend = [Saturday, Sunday]
        
    holidaydict = {
    "New Year's Day"    : '(d == 1 and m == January)',
    "Good Friday"       : '(date== gf)',
    "Easter Monday"     : '(date == em)',
    "Labour Day"        : '(d == 1 and m == May)',
    "Ascension Day"     : '(date == es + 39 * dayoffset)',
    "Whit Monday"       : '(date == es + 50 * dayoffset)',
    "Corpus Christi"    : '(date == es + 60 * dayoffset)',
    "Day of German Unity": '(d == 17 and m == June and (y < 1990 and y > 1953))',
    "German Unity Day"  : '(d == 3 and m == October and y >= 1990)',
    "All Saints"        : '(d == 1 and m == November)',
    "Day of Repentance and Prayer"  : '((d < 23 and d > 16) and w == Wednesday and m == November and y < 1995)',
    "Christmas"         : '(d == 25 and m == December)',
    "Christmas Day"     : '(d == 26 and m == December)'
    }

class SL(HolidayProfile):

    """ Holiday Profile for Germany/Saarland.
        Source: http://en.wikipedia.org/wiki/Public_holidays_in_Germany
        
        >>> German_Unity = datetime(2010, 10, 03) #Sunday
        >>> SL.holiday(German_Unity)
        'German Unity Day'
        
        >>> SL.isHoliday(German_Unity)
        True

        >>> SL.isBusinessDay(German_Unity)
        False
        
        >>> SL.isWeekend(German_Unity)
        True
    """

    weekend = [Saturday, Sunday]
        
    holidaydict = {
    "New Year's Day"    : '(d == 1 and m == January)',
    "Good Friday"       : '(date== gf)',
    "Easter Monday"     : '(date == em)',
    "Labour Day"        : '(d == 1 and m == May)',
    "Ascension Day"     : '(date == es + 39 * dayoffset)',
    "Whit Monday"       : '(date == es + 50 * dayoffset)',
    "Corpus Christi"    : '(date == es + 60 * dayoffset)',
    "Day of German Unity": '(d == 17 and m == June and (y < 1990 and y > 1953))',
    "German Unity Day"  : '(d == 3 and m == October and y >= 1990)',
    "All Saints"        : '(d == 1 and m == November)',
    "Day of Repentance and Prayer"  : '((d < 23 and d > 16) and w == Wednesday and m == November and y < 1995)',
    "Christmas"         : '(d == 25 and m == December)',
    "Christmas Day"     : '(d == 26 and m == December)'
    }

class SN(HolidayProfile):

    """ Holiday Profile for Germany/Sachsen.
        Source: http://en.wikipedia.org/wiki/Public_holidays_in_Germany
        
        >>> German_Unity = datetime(2010, 10, 03) #Sunday
        >>> SN.holiday(German_Unity)
        'German Unity Day'
        
        >>> SN.isHoliday(German_Unity)
        True

        >>> SN.isBusinessDay(German_Unity)
        False
        
        >>> SN.isWeekend(German_Unity)
        True
    """

    weekend = [Saturday, Sunday]
        
    holidaydict = {
    "New Year's Day"    : '(d == 1 and m == January)',
    "Good Friday"       : '(date== gf)',
    "Easter Monday"     : '(date == em)',
    "Labour Day"        : '(d == 1 and m == May)',
    "Ascension Day"     : '(date == es + 39 * dayoffset)',
    "Whit Monday"       : '(date == es + 50 * dayoffset)',
    "Corpus Christi"    : '(date == es + 60 * dayoffset) #Only in a few Sorbian communities.',
    "Day of German Unity": '(d == 17 and m == June and (y < 1990 and y > 1953))',
    "Assumption Day"    : '(d == 15 and m == August)',
    "German Unity Day"  : '(d == 3 and m == October and y >= 1990)',
    "Reformation Day"   : '(d == 31 and m == October)',
    "Day of Repentance and Prayer"  : '((d < 23 and d > 16) and w == Wednesday and m == November)',
    "Christmas"         : '(d == 25 and m == December)',
    "Christmas Day"     : '(d == 26 and m == December)'
    }

class SA(HolidayProfile):

    """ Holiday Profile for Germany/Sachsen-Anhalt.
        Source: http://en.wikipedia.org/wiki/Public_holidays_in_Germany
        
        >>> German_Unity = datetime(2010, 10, 03) #Sunday
        >>> SA.holiday(German_Unity)
        'German Unity Day'
        
        >>> SA.isHoliday(German_Unity)
        True

        >>> SA.isBusinessDay(German_Unity)
        False
        
        >>> SA.isWeekend(German_Unity)
        True
    """

    weekend = [Saturday, Sunday]
        
    holidaydict = {
    "New Year's Day"    : '(d == 1 and m == January)',
    "Epiphany"          : '(d == 6 and m == January)',  
    "Good Friday"       : '(date== gf)',
    "Easter Monday"     : '(date == em)',
    "Labour Day"        : '(d == 1 and m == May)',
    "Ascension Day"     : '(date == es + 39 * dayoffset)',
    "Whit Monday"       : '(date == es + 50 * dayoffset)',
    "Day of German Unity": '(d == 17 and m == June and (y < 1990 and y > 1953))',
    "Assumption Day"    : '(d == 15 and m == August)',
    "German Unity Day"  : '(d == 3 and m == October and y >= 1990)',
    "Reformation Day"   : '(d == 31 and m == October)',
    "Day of Repentance and Prayer"  : '((d < 23 and d > 16) and w == Wednesday and m == November and y < 1995)',
    "Christmas"         : '(d == 25 and m == December)',
    "Christmas Day"     : '(d == 26 and m == December)'
    }

class SH(HolidayProfile):

    """ Holiday Profile for Germany/Schleswig-Holstein.
        Source: http://en.wikipedia.org/wiki/Public_holidays_in_Germany
        
        >>> German_Unity = datetime(2010, 10, 03) #Sunday
        >>> SH.holiday(German_Unity)
        'German Unity Day'
        
        >>> SH.isHoliday(German_Unity)
        True

        >>> SH.isBusinessDay(German_Unity)
        False
        
        >>> SH.isWeekend(German_Unity)
        True
    """

    weekend = [Saturday, Sunday]
        
    holidaydict = {
    "New Year's Day"    : '(d == 1 and m == January)',
    "Good Friday"       : '(date== gf)',
    "Easter Monday"     : '(date == em)',
    "Labour Day"        : '(d == 1 and m == May)',
    "Ascension Day"     : '(date == es + 39 * dayoffset)',
    "Whit Monday"       : '(date == es + 50 * dayoffset)',
    "Day of German Unity": '(d == 17 and m == June and (y < 1990 and y > 1953))',
    "Assumption Day"    : '(d == 15 and m == August)',
    "German Unity Day"  : '(d == 3 and m == October and y >= 1990)',
    "Day of Repentance and Prayer"  : '((d < 23 and d > 16) and w == Wednesday and m == November and y < 1995)',
    "Christmas"         : '(d == 25 and m == December)',
    "Christmas Day"     : '(d == 26 and m == December)'
    }

class TH(HolidayProfile):

    """ Holiday Profile for Germany/Thueringen.
        Source: http://en.wikipedia.org/wiki/Public_holidays_in_Germany
        
        >>> German_Unity = datetime(2010, 10, 03) #Sunday
        >>> TH.holiday(German_Unity)
        'German Unity Day'
        
        >>> TH.isHoliday(German_Unity)
        True

        >>> TH.isBusinessDay(German_Unity)
        False
        
        >>> TH.isWeekend(German_Unity)
        True
    """

    weekend = [Saturday, Sunday]
        
    holidaydict = {
    "New Year's Day"    : '(d == 1 and m == January)',
    "Good Friday"       : '(date== gf)',
    "Easter Monday"     : '(date == em)',
    "Labour Day"        : '(d == 1 and m == May)',
    "Ascension Day"     : '(date == es + 39 * dayoffset)',
    "Whit Monday"       : '(date == es + 50 * dayoffset)',
    "Corpus Christi"    : '(date == es + 60 * dayoffset) #OOnly in the Catholic district of Eichsfeld..',
    "Day of German Unity": '(d == 17 and m == June and (y < 1990 and y > 1953))',
    "Assumption Day"    : '(d == 15 and m == August)',
    "German Unity Day"  : '(d == 3 and m == October and y >= 1990)',
    "Reformation Day"   : '(d == 31 and m == October)',
    "Day of Repentance and Prayer"  : '((d < 23 and d > 16) and w == Wednesday and m == November and y < 1995)',
    "Christmas"         : '(d == 25 and m == December)',
    "Christmas Day"     : '(d == 26 and m == December)'
    }



if __name__ == "__main__" :
    import doctest
    doctest.testmod(verbose=True)
